<template>
  <div class="bdTable">
    <el-table
      :data="tableData"
      style="width: 100%"
    >
      <el-table-column
        v-if="tableHeader.type"
        :type="tableHeader.type"
        align="center"
        >
      </el-table-column>
      <el-table-column
        v-for="item in tableHeader.header"
        :key="item.prop"
        :prop="item.prop"
        :label="item.label"
        :align="item.align || 'center'"
        :minWidth="item.minWidth"
        :width="item.width"
        :show-overflow-tooltip="item.showOverflowTooltip || false"
      >
      <template slot-scope="scope">
        <span v-if="!item.type">{{ item.filter ? item.filter(scope.row) : scope.row[item.prop] }}</span>
        <div v-else-if="item.type === 'switch'">
          <el-switch
            v-model="scope.row[item.prop]"
            active-color="#13ce66"
            inactive-color="#ff4949"
            @change="item.handler(scope.row)"
          >
          </el-switch>
        </div>
        <div v-else-if="item.type === 'button'">
          <bdButton :handlerBtn="item.btn" :scope="scope"></bdButton>
        </div>
      </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import bdButton from '../../components/bdButton/index.vue'
export default {
  name: 'bdTable',
  components: {
    bdButton
  },
  props: {
    tableHeader: {
      type: [Object, Array],
      required: true
    },
    tableData: {
      type: Array,
      default: () => []
    }
  },
  data () {
    return {}
  },
  // 计算属性
  computed: {},
  watch: {},
  mounted () {
    // console.log(this.tableData)
  },
  methods: {}
}
</script>

<style lang="scss" scoped>

</style>
